/*
类适配器模式
*/
class Source{
public:
    void app1(){
        printf("This is Source app1.\n");
    }
};


class Target{
public:
    // virtual void app1() = 0;
    virtual void app2() = 0;
    virtual ~Target() {}
};


class Adapter_class : public Source, public Target{
public:
    void app2(){
        printf("This is adapter_class app2.\n");
    }
};


/*
对象适配器模式
*/
class Target2{
public:
    virtual void app1() = 0;
    virtual void app2() = 0;
    virtual ~Target2() {}
};

class Adapter_object : public Target2{
private:
    Source* psource;
public:
    Adapter_object(Source* s) : psource(s) {}

    void app1(){
        psource->app1();
    }
    void app2(){
        printf("This is adapter_object app2.\n");
    }
};


/*
接口适配器模式
*/
class Subject_port{
public:
    virtual void app1() = 0;
    virtual void app2() = 0;
    virtual void app3() = 0;
    virtual void app4() = 0;
};

class Base_port : public Subject_port{
public:
    void app1() {}
    void app2() {}
    void app3() {}
    void app4() {}
};

class child1 : public Base_port{
public:
    void app1(){
        printf("This is child1 app1. \n");
    }
    void app3(){
        printf("This is child1 app3. \n");
    }
};

class child2 : public Base_port{
public:
    void app1(){
        printf("This is child12 app1. \n");
    }
    void app2(){
        printf("This is child12 app2. \n");
    }
    void app4(){
        printf("This is child12 app4. \n");
    }
};